﻿;; Booleans
(define (not x)
	(if x #f #t))
(define (boolean? x)
	(cond ((eq? x '#t) #t)
			((eq? x '#f) #t)
			((eq? x #t) #t)
			((eq? x #f) #t)
			(else #f)))

;; Numbers
(define (positive? n)
  (> n 0))

(define (negative? n)
  (< n 0))

(define (min x1 x2 . xs)
  (define (min2 a b)
    (if (< a b) a b))
  (reduce min2 0 (append (list x1 x2) xs)))

(define (max x1 x2 . xs)
  (define (max2 a b)
    (if (> a b) a b))
  (reduce max2 0 (append (list x1 x2) xs)))

;; Environments
(define (scheme-report-environment n) 
	(if (= n 5)
	system-global-environment
	(error "Cannot provide an environment for this Scheme Report: " n)))

;; Type checking
(define (check-arg pred val caller)
   (let lp ((val val))
     (if (pred val) val (lp (error "Bad argument" val pred caller)))))
